//
//  HDEasterEggsRegistrationCenter.m
//  TestEasterEggs
//
//  Created by Mirko on 15/8/10.
//  Copyright (c) 2015年 Mirko. All rights reserved.
//

#import "HDEasterEggsRegistrationCenter.h"
#import "UserDefaultsUtils.h"
#import "CrashListViewController.h"
#import "MCBasicAppEngine.h"

@interface HDEasterEggsRegistrationCenter () <HDEasterEggsDataSource, HDEasterEggsDelegate>


@end

@implementation HDEasterEggsRegistrationCenter

-(instancetype)init
{
    self = [super init];
    if (self) {
        self.classArray = [NSMutableArray array];
        // 配置那些需要单独创建的类
        [self installObjects];
    }
    return self;
}

- (void)installObjects
{
    [self registerObject:self];
    MCBasicViewController *vc = [CrashListViewController loadMCIBVCIdentifier:nil];
    [self registerObject:vc];
}

- (void)registerObject:(id)object
{
    if (![self isEasterEggsObject:object]) {
        DLOG(@"Warning object is easter eggs object!");
        return;
    }
    [self.classArray addObject:object];
}

- (BOOL) isEasterEggsObject:(NSObject *) object
{
    BOOL result = NO;
    result = [object respondsToSelector:@selector(cellInfo)];
    return result;
}

#pragma mark HDEasterEggsDataSource
-(HDEETableCellModel *) cellInfo
{
    HDEETableCellModel *model = [HDEETableCellModel model];
    model.cellTitle = @"清理 UserDefault";
    model.type = kHDEasterEggsCellTypeForDefault;
    model.identifier = @"CleanUserDefault";
    return model;
}

-(void) handleCellAction
{
    [MCBasicAppEngine showTostAlert:@"清理完成"];
    [UserDefaultsUtils print];
    [UserDefaultsUtils cleanAllUserValue];
    [UserDefaultsUtils print];
    DLOG();
}
@end
